<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" import="com.ym.utils.StringHandler" %>
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <title>修改app信息</title>
  <meta name="renderer" content="webkit" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  <link rel="stylesheet" href="../../static/lib/layui/css/layui.css" media="all" />
  <link rel="stylesheet" href="../../static/css/admin.css" media="all" />
</head>

<body>
<div id="TMM_app">
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" id="form" action="${path}/app/update/edit" method="post" lay-filter="component-form-group">
          <div class="form-title">基本信息</div>
          <input type="hidden" name="id" id="id" value="${appInfo.id}">
          <div class="layui-row">
            <div class="layui-col-md9 layui-col-lg6">
              <div class="layui-form-item">
                <label class="layui-form-label">app名称</label>
                <div class="layui-input-block">
                  <input type="text" name="app_name" value="${appInfo.app_name}" lay-verify="required" autocomplete="off" class="layui-input" disabled="disabled"/>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">终端</label>
                <div class="layui-input-block">
                  <input type="text" name="terminal" value="${appInfo.terminal}" lay-verify="required" autocomplete="off" class="layui-input" disabled="disabled"/>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">app版本(ios用)</label>
                <div class="layui-input-block">
                  <input type="text" name="app_version" value="${appInfo.app_version}" lay-verify="required" autocomplete="off" class="layui-input" />
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">app升级版本(android用)</label>
                <div class="layui-input-block">
                  <input type="text" name="version_code" value="${appInfo.version_code}" lay-verify="required" autocomplete="off" class="layui-input" />
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">app审核版本(android用)</label>
                <div class="layui-input-block">
                  <input type="text" name="version" value="${appInfo.version}" lay-verify="required" autocomplete="off" class="layui-input" />
                </div>
              </div>
              <div class="layui-row">
                <div class="layui-col-md6 layui-col-lg6">
                  <div class="layui-form-item">
                    <label class="layui-form-label">是否强制更新</label>
                    <div class="layui-input-block">
                      <input type="radio" name="is_forced_updating" lay-verify="otherReq" value="1" title="是" <c:if test="${appInfo.is_forced_updating}">checked</c:if>>
                      <input type="radio" name="is_forced_updating" lay-verify="otherReq" value="0" title="否" <c:if test="${!appInfo.is_forced_updating}">checked</c:if>>
                    </div>
                  </div>
                </div>
              </div>
              <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">更新内容</label>
                <div class="layui-input-block">
                  <textarea name="updating_content" placeholder="请输入更新内容" class="layui-textarea">${appInfo.updating_content}</textarea>
                </div>
              </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">下载路径</label>
                    <div class="layui-input-block">
                        <input type="text" id="app_url" name="app_url" value="${appInfo.app_url}" lay-verify="required" autocomplete="off" class="layui-input" />
                    </div>
                </div>
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <div class="layui-footer">
                <button class="layui-btn tmm-btn-primary" type="button" lay-submit="" lay-filter="component-form-demo1">
                  提交
                </button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<script src="../../static/lib/layui/layui.js"></script>
<script>
  layui.config({
    base: "../../static/js/"
  }).extend({
    index: 'index' //主入口模块
  }).use(["index", "form", "laydate", "upload"], function () {
    var $ = layui.$,
            layer = layui.layer,
            form = layui.form;

    form.render(null, "component-form-group");

    form.render();

    /* 监听指定开关 */
    form.on("switch(component-form-switchTest)", function (data) {
      layer.msg("开关checked：" + (this.checked ? "true" : "false"), {
        offset: "6px"
      });
      layer.tips(
              "温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF",
              data.othis
      );
    });

    /* 监听提交 */
    form.on("submit(component-form-demo1)", function (data) {
      var action = $("#form").attr("action");
      var index = layer.load(2);
      $.ajax({
        type:"post",
        url:action,
        dataType:"json",
        data:$('#form').serialize(),
        success:function(data){
          layer.close(index);
          if(data.code ==0){
            layer.alert(data.msg,{icon:1}, function(){
              location.reload();
            });
          }else{
            layer.alert(data.msg,{icon:2});
          }
        },
        error:function (data) {
          layer.close(index);
        }
      });
      return false;
    });
  });
</script>
</body>

</html>